/**
 * Created by 123 on 2017/12/8.
 * 签退
 */

import React from 'react'
import {connect} from 'dva-no-router'
import {bindActionCreators} from 'redux'

import UI from '../components/signOut';

class App extends React.Component {

  componentDidMount() {
    const {querySignInfo}=this.props;
    querySignInfo()
  }

    componentWillUnmount(){
        const {getClean}=this.props;
        getClean();
    }
  render() {
    return (
      <UI {...this.props}/>
    )
  }
}

const actions = {
  /**
   * 获取签退信息
   * @param id 任务id
   */
  querySignInfo: () => ({type: 'signOut/querySignInfo'}),

  /**
   * 设置签退地点
   * @param place 签到地点（经度,纬度）
   */
  setSignPlace: (place) => ({type: 'signOut/setSignPlace', payload: place}),

  /**
   * 选择签退人员
   * @param id 人员Id
   */
  setCurrentUserList: (id) => ({type: 'signOut/setCurrentUserList', payload: id}),

  /**
   * 签退
   */
  signIn: () => ({type: 'signOut/signIn'}),

  /**
   * 签退时间
   */
  setSignTime: (time) => ({type: 'signOut/setSignTime',payload:time}),

    getClean:() =>({type:'signOut/getClean'}),
  addPictures:(val) =>({type:'signOut/addPictures',payload:val}),
};

const mapProps = ({signOut}) => ({...signOut});

const mapActions = dispatch => ({
  ...bindActionCreators({...actions}, dispatch)
});

export default connect(mapProps, mapActions)(App)